﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;

using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
using DAL;
public partial class Admin_NameEdte : System.Web.UI.Page
{
    DataTable dt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!AdminCheck.Check(this, 1))
        {
            Response.Redirect(AdminCheck.RedirectPage);
            return;
        }
        if (!Page.IsPostBack)
        {


            string lb = Request.QueryString["no"].ToString();



            List<TnoInfo> lst = new WayBillService().GetList(lb, 4);

            dt = new WayBillService().GetShipmentList(lst);


            list.DataSource = lst;
            list.DataBind();

            Rpt_Name.DataSource = new PublicSqlService().GetData("GoodsName", "Tbl_SplitBillGoods", "");
            Rpt_Name.DataBind();


        }
    }


    protected void okbtn_Click(object sender, ImageClickEventArgs e)
    {

        int sum = 0;
        Hashtable hs = new Hashtable();
        for (int i = 0; i < list.Items.Count; i++)
        {




            Label no = (Label)list.Items[i].FindControl("no_txt");
            HtmlInputText name = (HtmlInputText)list.Items[i].FindControl("name");
            HtmlInputText num = (HtmlInputText)list.Items[i].FindControl("num");
            HtmlInputText weight = (HtmlInputText)list.Items[i].FindControl("weight");

            hs.Add("Commodity", name.Value);
            hs.Add("Qty", new Tools().StringToIntDif(num.Value));



        }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="No">单号</param>
    /// <param name="type">1 货物ID，2 货物名字，3 货物数量 4 货物 海关</param>
    /// <param name="i"></param>
    /// <returns></returns>
    public string Getid(string No, int type, int i)
    {


        if (dt.Rows.Count == 0)
        {
            return "";
        }
 

        DataView dv = dt.DefaultView;
        dv.RowFilter = "TrackingNo='" + No.ToString() + "'";


        DataTable ndt = dv.ToTable();

        if (ndt.Rows.Count < i + 1)
        {

            return "";
        }
        switch (type)
        {
            case 1:

                return ndt.Rows[i]["MID"].ToString();
            case 2:
                return ndt.Rows[i]["Commodity"].ToString();
            case 3:
                return ndt.Rows[i]["Qty"].ToString();
            case 4:
                return ndt.Rows[i]["ValueForCustoms"].ToString();
            default:
                break;
        }

   
        return "";

         ndt.Dispose();


    }
}




